﻿CREATE PROCEDURE [dbo].[proc_Orders_GetList_Project_Count]
(
		@CompanyId int,
		@SText nvarchar(50),
		@StartDate nvarchar(50),
		@EndDate nvarchar (50),
		@ProductId int
	)
AS
Begin
	Select Count(Id) From Orders
	Where (@CompanyId=0 Or CompanyId=@CompanyId) And FinanceFlag=1 And (@SText is null Or CustomerName like '%'+ @SText +'%' Or EName like '%'+ @SText +'%' Or BaiDuAccount like '%'+@SText+'%')
		  and (Convert(varchar(10),FixtureDate,120)>=@StartDate and Convert(varchar(10),FixtureDate,120)<=@EndDate)
          and (@ProductId=0 or MainProjectId=@ProductId)
End
	RETURN
